package map;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo02 {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
        Integer I = map.put("语文", 99);
        map.put("数学",100);
        map.put("英语",99);
        map.put("物理",99);
        map.put("化学",99);

        Set<String> keySet = map.keySet();
        for (String key : keySet){
            System.out.println("key:"+key);
        }

        Set<Map.Entry<String,Integer>> entrySet = map.entrySet();
        for (Map.Entry<String,Integer> entry : entrySet){
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+","+value);
        }

        Collection<Integer> values = map.values();
//        for (Integer value :values){
//            System.out.println("value:"+value);
//        }

        //遍历集合
        values.forEach(e-> System.out.println(e));
//        values.forEach(System.out::println);

        map.forEach((k,v)-> System.out.println(k+","+v));
 }
}
